package com.example.myanimator.one;

import androidx.appcompat.app.AppCompatActivity;

import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.example.myanimator.R;
import com.example.myanimator.SecondActivity;
import com.example.myanimator.five.FiveActivity;
import com.example.myanimator.six.SixActivity;

public class MainActivity extends AppCompatActivity {

    private SlideTextView slideTextView;
    private ThumbsUpView thumbsUpView;
    private TextView tv1;
    private   ObjectAnimator    animator;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv1 = findViewById(R.id.tv_1);
        slideTextView = findViewById(R.id.tv_slide);
        thumbsUpView = findViewById(R.id.thum_view);
        slideTextView.setSumLike(0);
        findViewById(R.id.constraintlayout).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                slideTextView.changeLike();
                thumbsUpView.changeLike();
                animator.start();
            }
        });
        findViewById(R.id.tv_5).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this, SecondActivity.class));
            }
        });
        findViewById(R.id.tv_7).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this, FiveActivity.class));
            }
        });

        findViewById(R.id.tv_8).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this, SixActivity.class));
            }
        });
        animator = ObjectAnimator.ofFloat(tv1, "animProgress", 0f, 100f);
        animator.setDuration(5000);
        animator.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

            }

            @Override
            public void onAnimationEnd(Animator animation) {
                tv1.setText(Integer.valueOf(tv1.getText().toString())+1+"");
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });

    }
}